//
//  XMCameraTimeCollectionViewCell.m
//  XiaoMiao
//
//  Created by Jim huang on 2018/4/22.
//  Copyright © 2018年 smallyou. All rights reserved.
//

#import "XMCameraTimeCollectionViewCell.h"

@interface XMCameraTimeCollectionViewCell ()

@property (nonatomic,strong) UIImageView * imageSelectedView;

@end

@implementation XMCameraTimeCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setUI];
    }
    return self;
}

-(void)setUI{
    
    self.layer.borderColor = kBgColor.CGColor;
    self.layer.borderWidth = 1;
    self.layer.cornerRadius = self.height/2;
    self.clipsToBounds = YES;
    self.backgroundColor = KItemNormalColor;
    //标题
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.contentView);
    }];
    //选择图
    [self.imageSelectedView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(self.contentView).offset(1.5);
        make.right.bottom.equalTo(self.contentView).offset(-1.5);
    }];
    
    [self.contentView bringSubviewToFront:self.titleLabel];
}

#pragma mark ----getting&setting---

//标题
-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = kBlackColor;
        _titleLabel.font = kFont(14);
        _titleLabel.text = @"术前";
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

//选择图
-(UIImageView *)imageSelectedView{
    if (!_imageSelectedView) {
        _imageSelectedView = [[UIImageView alloc]init];
        [self.contentView addSubview:_imageSelectedView];
    }
    return _imageSelectedView;
}

-(void)setItemSelected:(BOOL)itemSelected{
    _itemSelected = itemSelected;
    if (itemSelected) {
        self.titleLabel.textColor = kMainBlueColor;
        [self.imageSelectedView setImage:kImage(@"cameraTime_selected")];
        self.backgroundColor = KItemSelectedColor;
        self.layer.borderColor = kWhiteColor.CGColor;


    }else{
        self.titleLabel.textColor = kBlackColor;
        [self.imageSelectedView setImage:nil];
        self.backgroundColor = KItemNormalColor;
        self.layer.borderColor = kBgColor.CGColor;

    }
    
}


@end
